package com.ggk911.pharmacy_system.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ggk911.pharmacy_system.entity.User;
import com.ggk911.pharmacy_system.mapper.UserMapper;
import com.ggk911.pharmacy_system.service.IUserService;
import org.springframework.stereotype.Service;

/**
 * @author ggk-911
 * @version 1.0 2023/3/8 10:45
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    //登录方法
    @Override
    public User login(String name, String pwd) {
        return baseMapper.login(name, pwd);
    }

    /**
     * 重写的page(E page, Wrapper<User> queryWrapper)
     *
     * @param page
     * @param queryWrapper
     * @param <E>
     * @return
     */
    @Override
    public <E extends IPage<User>> E page(E page, Wrapper<User> queryWrapper) {
        return baseMapper.selectPage(page, queryWrapper);
    }

    /**
     * 重写的page(E page)
     * @param page
     * @param <E>
     * @return
     */
    @Override
    public <E extends IPage<User>> E page(E page) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.ne("role_id", "1");
        return baseMapper.selectPage(page, wrapper);
    }
}
